/*------------- handler.hpp
* Copyright (C): 2015  Cage
* Author       : Cage
* Create Date  : 2015/01/13 17:32:37
* Version      : V1.01
*
*/
/***************************************************************
* 
***************************************************************/
#ifndef __ZCODE_NETWORK_HANDLER_HPP__
#define __ZCODE_NETWORK_HANDLER_HPP__
/*************************************************************/
#include <zcode/network/network_fwd.hpp>

namespace zcode
{
  namespace network
  {
    class Handler
    {
      public:
        typedef boost::function<void(SessionID)> ConnectHandler;
        typedef boost::function<void(SessionID)> DisconnectHandler;
        typedef boost::function<void(SessionID, const char*, size_t, const ErrorCode& ec)> ReceiveHandler;
        typedef boost::function<void(SessionID, const ErrorCode& ec)> ErrorHandler;

      public:
        Handler()
          : connect_handler_(), disconnect_handler_(), receive_handler_(), error_handler_()
        {}
        virtual ~Handler()
        {}

        void bind_connect_handler(const ConnectHandler& handler)
        {
          connect_handler_ = handler;
        }
        void bind_disconnect_handler(const DisconnectHandler& handler)
        {
          disconnect_handler_ = handler;
        }
        void bind_receive_handler(const ReceiveHandler& handler)
        {
          receive_handler_ = handler;
        }
        void bind_error_handler(const ErrorHandler& handler)
        {
          error_handler_ = handler;
        }

      protected:
        ConnectHandler connect_handler_;
        DisconnectHandler disconnect_handler_;
        ReceiveHandler receive_handler_;
        ErrorHandler error_handler_;
    };
  }// namespace network
}//namespace zcode
/*************************************************************/
#endif///__ZCODE_NETWORK_HANDLER_HPP__
